package cn.hrlly.tao2shou.biz;

import com.zhy.http.okhttp.OkHttpUtils;

import cn.hrlly.tao2shou.other.Config;
import cn.hrlly.tao2shou.callback.ClassifyCommoditiesCallback;
import cn.hrlly.tao2shou.domain.CommodityList;
import cn.hrlly.tao2shou.listener.OnClassifyCommoditiesListener;

/**
 * User: gengliang
 * Date: 2016-01-29
 * Time: 19:03
 */

public class ClassifyCommoditiesBizImpl implements ClassifyCommoditiesBiz {

    private OnClassifyCommoditiesListener onClassifyCommoditiesListener;

    public ClassifyCommoditiesBizImpl(OnClassifyCommoditiesListener onClassifyCommoditiesListener){
        this.onClassifyCommoditiesListener=onClassifyCommoditiesListener;
    }

    @Override
    public void showClassifyCommodities(CommodityList commodityList) {
        OkHttpUtils
                .post()
                .url(Config.key_url)
                .addParams(Config.key_action,Config.action_classify_commodities)
                .addParams(Config.key_classification,commodityList.getClassification())
                .addParams(Config.key_page, String.valueOf(commodityList.getPage()))
                .addParams(Config.key_page_count, String.valueOf(commodityList.getPageCount()))
                .addParams(Config.key_sort_according, String.valueOf(commodityList.getSortAccording()))
                .addParams(Config.key_longditude, String.valueOf(commodityList.getLongitude()))
                .addParams(Config.key_lantitude, String.valueOf(commodityList.getLantitude()))
                .build()
                .execute(new ClassifyCommoditiesCallback(onClassifyCommoditiesListener));
    }
}
